home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
tex
/
td187src.lzh
/
CIRCLES.I
< prev
next >
Wrap
Text File
|
1991-12-14
|
22KB
|
662 lines
IMPLEMENTATION MODULE Circles ;
FROM Types IMPORT TextPosTyp;
IMPORT Types;
IMPORT mtAppl;
IMPORT Diverses;
IMPORT MagicAES;
IMPORT MagicVDI;
IMPORT MagicSys;
IMPORT MathLib0 ;
IMPORT OwnBoxes;
IMPORT Variablen ;
IMPORT CommonData ;
IMPORT HelpModule;
IMPORT Fill;
IMPORT Undo;
TYPE mkMode = (mkQuarter, mkCircle, mkDisk, mkArc, mkEllipse, mkEllArc);
CONST HorizLines = 0;
VertiLines = 1;
DiagLftLines = 2;
DiagRgtLines = 3;
PROCEDURE Make ( Mode : mkMode; FillMode : INTEGER ) ;
VAR rx , ry , mx, my, rox, roy,
r, dx1, dx2, dy1, dy2,
x , y , b , e , bo , eo , xpic, ypic,
dum, h, mr : INTEGER ;
keystate, but : BITSET ;
fillstyle, fillstyleindex : INTEGER ;
xy : Types.CodeAryTyp ;
Surround : ARRAY [0..3] OF INTEGER;
halfcircle : BOOLEAN;
lbut, rbut, allok : BOOLEAN;
startangle, endangle : INTEGER;
xold, yold : INTEGER;
hlppos1, hlppos2 : INTEGER;
HelpAngle1,
HelpAngle2,
HelpEllipse,
HelpQuarter,
HelpHalf,
HelpFull : ARRAY [0..59] OF CHAR;
PROCEDURE ReplaceAngleVal(VAR str : ARRAY OF CHAR;
angleval, strpos : INTEGER);
VAR dum : INTEGER;
BEGIN
IF strpos>0 THEN
str[strpos] := CHR(ORD('0') + MagicSys.CastToCard(angleval DIV 100));
dum := angleval MOD 100;
str[strpos+1] := CHR(ORD('0') + MagicSys.CastToCard(dum DIV 10));
str[strpos+2] := CHR(ORD('0') + MagicSys.CastToCard(dum MOD 10));
END;
END ReplaceAngleVal;
PROCEDURE NewAngleVal(VAR angle, xold, x : INTEGER;
keystate : BITSET);
VAR shift, ctrl, alt : BOOLEAN;
BEGIN
shift := (MagicAES.KRSHIFT IN keystate) OR
(MagicAES.KLSHIFT IN keystate);
ctrl := MagicAES.KCTRL IN keystate;
alt := MagicAES.KALT IN keystate;
IF (xold<x) THEN
IF shift THEN
DEC(angle, 5);
ELSIF alt AND NOT ctrl THEN
(* auf nächst niedrigeren Wert *)
IF angle = 0 THEN
angle := -45;
ELSE
angle := ((angle-1) DIV 45) * 45;
END;
ELSIF ctrl AND NOT alt THEN
(* auf nächst niedrigeren Wert *)
IF angle = 0 THEN
angle := -90;
ELSE
angle := ((angle-1) DIV 90) * 90;
END;
ELSIF ctrl AND alt THEN
(* auf nächst niedrigeren Wert *)
IF angle = 0 THEN
angle := -180;
ELSE
angle := ((angle-1) DIV 180) * 180;
END;
ELSE
DEC(angle, 1);
END;
ELSE
IF shift THEN
INC(angle, 5);
ELSIF alt AND NOT ctrl THEN
(* auf nächst höheren Wert *)
angle := ((angle DIV 45) +1) * 45;
ELSIF ctrl AND NOT alt THEN
(* auf nächst höheren Wert *)
angle := ((angle DIV 90) +1) * 90;
ELSIF ctrl AND alt THEN
(* auf nächst höheren Wert *)
angle := ((angle DIV 180) +1) * 180;
ELSE
INC(angle, 1);
END;
END;
xold := x;
WHILE (angle>360) DO DEC(angle, 360); END;
WHILE (angle< 0) DO INC(angle, 360); END;
END NewAngleVal;
BEGIN
OwnBoxes.WaitForDepress(mx, my);
Diverses.GetHelpText(6, HelpEllipse);
Diverses.GetHelpText(6, HelpQuarter);
Diverses.GetHelpText(7, HelpHalf);
Diverses.GetHelpText(8, HelpFull);
Diverses.GetHelpText(9, HelpAngle1);
Diverses.GetHelpText(10, HelpAngle2);
hlppos1 := 0;
WHILE (HelpAngle1[hlppos1]<>0C) AND (HelpAngle1[hlppos1]<>'?') DO
INC(hlppos1);
END;
IF (HelpAngle1[hlppos1 ]<>'?') OR
(HelpAngle1[hlppos1+1]<>'?') OR
(HelpAngle1[hlppos1+2]<>'?') THEN
hlppos1 := -1;
END;
hlppos2 := 0;
WHILE (HelpAngle2[hlppos2]<>0C) AND (HelpAngle2[hlppos2]<>'?') DO
INC(hlppos2);
END;
IF (HelpAngle2[hlppos2 ]<>'?') OR
(HelpAngle2[hlppos2+1]<>'?') OR
(HelpAngle2[hlppos2+2]<>'?') THEN
hlppos2 := -1;
END;
mr := Variablen.MaxCircle() ;
IF (Mode = mkDisk) AND (FillMode=0) THEN
mr := Variablen.MaxDisk() ;
END ;
mr := Variablen.PixDistance ( mr );
rox := 0 ;
roy := 0 ;
b := 0 ;
e := 3600 ;
h := 0 ;
bo := 0 ;
eo := 3600 ;
MagicVDI.SetLineEndstyles ( mtAppl.VDIHandle , MagicVDI.Cornerd , MagicVDI.Cornerd ) ;
dum := MagicVDI.SetLinetype ( mtAppl.VDIHandle , MagicVDI.Line ) ;
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
IF FillMode>=0 THEN
Fill.SetFillMode(FillMode);
END;
dum := MagicVDI.SetLinecolor ( mtAppl.VDIHandle , MagicAES.BLACK ) ;
REPEAT
OwnBoxes.GetMKState(x, y, but, keystate);
OwnBoxes.MousePos(x, y, xpic, ypic, lbut, rbut);
Variablen.Position (TRUE, x, y, mx, my ) ;
halfcircle := (MagicAES.KLSHIFT IN keystate) OR
(MagicAES.KRSHIFT IN keystate);
IF NOT ((Mode=mkEllipse) OR (Mode=mkEllArc)) THEN
rx := Diverses.round ( MathLib0.sqrt (
MathLib0.real ( x - mx ) * MathLib0.real ( x - mx ) +
MathLib0.real ( y - my ) * MathLib0.real ( y - my ) ) );
IF rx > mr THEN rx := mr END ;
ry := rx;
ELSE
rx := ABS(x-mx); ry := ABS(y-my);
END;
IF (rx <> rox) OR (ry <>roy) THEN
IF Mode = mkQuarter THEN
IF halfcircle THEN
HelpModule.HelpMessage(HelpHalf);
ELSE
HelpModule.HelpMessage(HelpQuarter);
END;
IF x - mx < 0 THEN (* linke Seite *)
IF halfcircle THEN
IF ABS(y-my)<=ABS(x-mx) THEN
b := 900; e := 2700;
h := ORD(Types.Left);
ELSE
IF (y-my)<0 THEN (* Y-Achse invers !! *)
b := 0; e := 1800;
h := ORD(Types.Top);
ELSE
b := 1800; e := 3600;
h := ORD(Types.Bottom);
END;
END;
ELSE
IF y - my < 0 THEN b := 900 ; e := 1800 ;
h := ORD(Types.LeftTop) ;
ELSE b := 1800 ; e := 2700 ;
h := ORD(Types.LeftBot) ;
END ;
END ;
ELSE (* rechte Seite *)
IF halfcircle THEN
IF ABS(y-my)<=ABS(x-mx) THEN
b := 2700; e := 900;
h := ORD(Types.Right);
ELSE
IF (y-my)<0 THEN (* Y-Achse invers !! *)
b := 0; e := 1800;
h := ORD(Types.Top);
ELSE
b := 1800; e := 3600;
h := ORD(Types.Bottom);
END;
END;
ELSE
IF y - my < 0 THEN b := 0 ; e := 900 ;
h := ORD(Types.RightTop) ;
ELSE b := 2700 ; e := 0 ;
h := ORD(Types.RightBot) ;
END ;
END ;
END ;
ELSIF (Mode = mkEllipse) OR (Mode=mkEllArc) THEN
HelpModule.HelpMessage(HelpEllipse);
ELSE
HelpModule.HelpMessage(HelpFull);
END ;
dum := MagicVDI.SetWritemode ( mtAppl.VDIHandle , MagicVDI.XOR ) ;
MagicVDI.SetClipping ( mtAppl.VDIHandle , CommonData.ClipXY , TRUE) ;
Diverses.MouseOff;
CASE Mode OF
mkDisk:
Fill.SetFillMode(FillMode);
MagicVDI.Circle ( mtAppl.VDIHandle , mx , my , rox ) ;
MagicVDI.Circle ( mtAppl.VDIHandle , mx , my , rx ) ;
Fill.SetFillMode(-1); |
mkEllArc,
mkEllipse:
IF FillMode>=0 THEN
Fill.SetFillMode(FillMode);
MagicVDI.Ellipse ( mtAppl.VDIHandle , mx , my , rox, roy);
MagicVDI.Ellipse ( mtAppl.VDIHandle , mx , my , rx, ry);
ELSE
MagicVDI.EllipticalArc ( mtAppl.VDIHandle , mx , my , rox, roy, bo, eo);
MagicVDI.EllipticalArc ( mtAppl.VDIHandle , mx , my , rx, ry,